// attaclnpc.txt
// Creature walks to the end of a path. Once it reaches the end, it becomes a hunter and
// tracks the party
// Memory Cells:
//   Cell 0 - Number of path to follow.
//	 Cell 1 - Node if talked to. 0 means no conversation
//   Cell 2,3 -  Stuff done flag. If both 0, nothing. Otherwise when this is killed, inc flag by 1.

begincreaturescript;

variables;

short i,target;
short followed_path = 0;

body;

beginstate INIT_STATE;
	break;

beginstate DEAD_STATE;
	if ((get_memory_cell(3) != 0) || (get_memory_cell(2) != 0))
		inc_flag(get_memory_cell(2),get_memory_cell(3),1);
break;

beginstate START_STATE;
	if (get_foe_target(ME,6,0)) {
		do_attack();
		set_state(3);
		}
	if (who_shot_me() >= 0) {
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}
	if (followed_path == 0) {
		set_state(4);
		}
		else if (get_attitude(ME) >= 10) {
			set_foe_target(ME,1000);
			set_state(3);
			}

break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);
	do_attack();
break;

beginstate 4; // patrol
	if (get_foe_target(ME,8,0)) {
		do_attack();
		set_state(3);
		}
	if (who_shot_me() >= 0) {
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}
	if (follow_path(ME,get_memory_cell(0),0) == TRUE) {
		followed_path = 1;
		set_state(START_STATE);
		}
break;
beginstate TALKING_STATE;
	if (get_memory_cell(1) == 0) {
		print_str("Talking: It doesn't respond.");
		}
		else begin_talk_mode(get_memory_cell(1));	
break;